<?php

namespace App\Controller\App;

use App\Base\BaseConfig;
use App\Base\BaseController4Restful;
use App\Repository\PageRepository;
use Symfony\Component\Routing\Annotation\Route;

class PageController extends BaseController4Restful
{
    /**
     * @Route("/app/page", name="AppGetSinglePage")
     */
    public function AppGetSinglePage(PageRepository $repository)
    {
        if(!$code = $this->getParamRequired("code")){return $this->json_out(0,"参数缺失");}

        $page = $repository->findOneBy(array("code"=>$code));
        if (!$page) {
            return $this->json_out(500,"关键数据缺失");
        }
        $page = $this->toArray($page);
        $page["content"] = $this->dealWithImgInHtml($page["content"]);
        return $this->json_out(200,"数据获取成功",$page);
    }
}
